<template>
  <view class="content">
    <image :src="avatar" mode="aspectFill" style="width: 100%; height: 300rpx;"></image>
    <view class="info-content">
      <u-cell size="large" title="姓名" :value="form.nickName"></u-cell>
      <u-cell size="large" title="律所名称" :value="form.firmName"></u-cell>
      <u-cell size="large" title="咨询费用" :value="form.consultationFee"></u-cell>
      <u-cell size="large" title="职称/头衔" :value="form.title"></u-cell>
      <u-cell size="large" title="工作年限" :value="form.workYears"></u-cell>
      <u-cell size="large" title="执业证号" :value="form.licenseNo"></u-cell>
      <u-cell size="large" title="教育背景" :value="form.educationBackground"></u-cell>
      <u-cell size="large" title="荣誉奖项" :value="form.honorAwards"></u-cell>
      <u-cell size="large" title="擅长案件" :value="form.specialties"></u-cell>
      <u-cell size="large" title="服务地区" :value="form.serviceArea"></u-cell>
      <u-cell size="large" title="是否推荐" :value="form.isRecommend ? '是' : '否'"></u-cell>
      <u-cell size="large" title="个人简介" :value="form.personalProfile"></u-cell>
    </view>
    <view class="foot">
      <u-button type="primary" text="留言" @click="goMessage"></u-button>
    </view>
  </view>
</template>

<script>
import { mapGetters } from 'vuex'
import lawyerApi from '../request/api/lawyer'
import config from '../request/config'
export default {
  options: { styleIsolation: 'shared' },
  data() {
    return {
      // 律师id
      lawyerId: '',
      // 是否为审核页面
      isReview: false,
      form: {},
      swiper: [],
      message: false
    }
  },
  computed: {
    ...mapGetters('userInfo', ['user']),
    avatar() {
      const avatar = this.form.avatar
      return avatar ? config.baseUrl + avatar : 'https://sanshengcai.com/home/images/logo.png'
    }
  },
  onLoad(option) {
    this.lawyerId = option.lawyerId
    this.getDetail()
  },
  // 下拉刷新
  async onPullDownRefresh() {
    await this.getDetail()
    uni.stopPullDownRefresh()
  },
  methods: {
    // 跳转与律师聊天页面
    goMessage() {
      uni.navigateTo({
        url: `/pages/common/index?heId=${ this.form.userId }`
      })
    },
    async getDetail() {
      uni.showLoading({
        title: '加载中',
        mask: true,
      });
      try {
        var { data } = await lawyerApi.getLawyerProfile(this.lawyerId)
      } catch (error) {
        return
      } finally {
        uni.hideLoading()
      }
      this.form = data
      this.swiper = this.form?.firmImages?.split(",")?.map(url => config.baseUrl + url) || []
    },
  },
  onShareAppMessage() {
    return {
      title: this.form.nickName,
      path: `/lawyer/profile?lawyerId=${ this.form.id }`, // 分享路径
    }
  }
}
</script>

<style>
.info-content .u-cell__value {
  width: 70%;
}
</style>

<style scoped lang="scss">
.foot {
  margin: 20rpx;
  padding-bottom: 0;  
  padding-bottom: constant(safe-area-inset-bottom);  
  padding-bottom: env(safe-area-inset-bottom); 
}
</style>
